{% extends 'backend.html' %}
{% load static %}
{% block add_article %}
    <div class="panel panel-success" style="margin-top: 20px">
        <div class="panel-heading">
            <h5>添加文章</h5>
        </div>
    </div>
    <form action="" method="post">
        {% csrf_token %}
        <div class="form-group">
            <label for="">文章标题:</label>
            <input type="text" name="article_title" class="form-control">
        </div>
        <div class="form-group">
            <label for="article_content">文章内容:</label>
            {#            <div id="test-editor">#}
            <textarea name="article_content" id="article_content" cols="30" rows="10"
                      class="form-control"></textarea>
            {#            </div>#}
        </div>
        <div class="form-group">
            <label for="">文章分类:</label>
            <select class="form-control" id="article_class" name="article-class">
                {% for category_obj in category_obj_all %}
                    <option value="{{ category_obj.pk }}">{{ category_obj.name }}</option>
                {% endfor %}

            </select>
        </div>
        <div class="form-group">
            <label for="">文章标签:</label>
            <select class="form-control" id="article_class" name="article-class" multiple>
                {% for tag_obj in tag_obj_all %}
                    <option value="{{ tag_obj.pk }}">{{ tag_obj.name }}</option>
                {% endfor %}
            </select>
        </div>
        <input type="submit" class="btn btn-success " value="发布">
    </form>

    <script type="text/javascript">
        $(function () {
            var editor = editormd("test-editor", {
                width: "auto",
                height: "400px",
                path: "/static/plugins/Editor/editor/lib/"
            });
        });
        KindEditor.ready(function (K) {
            window.editor = K.create(
                '#article_content', {
                    'width':'50%',
                    'height':'500px',
                    'themeType': 'simple',
                    "uploadJson": "{% url 'article_upload_img' %}",
                    "extraFileUploadParams": {
                    "csrfmiddlewaretoken": "{{ csrf_token }}"
                }
                });
        });
    </script>

{% endblock %}